package com.jtlrm.ckd.mvp.model;

import com.base.sdk.base.model.BaseModel;
import com.base.sdk.base.net.LifeCycleEvent;
import com.google.gson.JsonObject;
import com.jtlrm.ckd.entity.YingYangDetailData;
import com.jtlrm.ckd.net.RetrofitUtil;

import io.reactivex.Observer;
import io.reactivex.subjects.PublishSubject;

public class YinYangModel extends BaseModel {

    public void queryHistroy(String patientId, int PageIndex, int PageSize, Observer observer, PublishSubject<LifeCycleEvent> lifecycleSubject) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("patientId", patientId);
        jsonObject.addProperty("PageIndex", PageIndex);
        jsonObject.addProperty("PageSize", PageSize);
        RetrofitUtil.composeToSubscribe(RetrofitUtil.getService().queryYingYangHistory(jsonObject), observer, lifecycleSubject);
    }

    public void addYingYangData(YingYangDetailData submitData, Observer observer, PublishSubject<LifeCycleEvent> lifecycleSubject) {
        RetrofitUtil.composeToSubscribe(RetrofitUtil.getService().addYingYang(createBody(submitData)), observer, lifecycleSubject);
    }

    public void queryToDayDetail(String patientId, Observer observer, PublishSubject<LifeCycleEvent> lifecycleSubject) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("patientId", patientId);
        RetrofitUtil.composeToSubscribe(RetrofitUtil.getService().queryTodayYingYang(jsonObject), observer, lifecycleSubject);
    }

    public void updateYingYangData(YingYangDetailData submitData, Observer observer, PublishSubject<LifeCycleEvent> lifecycleSubject) {
        RetrofitUtil.composeToSubscribe(RetrofitUtil.getService().updateYingYang(createBody(submitData)), observer, lifecycleSubject);
    }

    public void deleteYingYangData(String patientId, Observer observer, PublishSubject<LifeCycleEvent> lifecycleSubject) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("patientId", patientId);
        RetrofitUtil.composeToSubscribe(RetrofitUtil.getService().deleteYingYang(jsonObject), observer, lifecycleSubject);
    }
}
